/**
 * 
 */
package com.hanhai.zrb.api.util;

import java.util.List;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.hanhai.zrb.model.common.PageList;

/**
 * @author ricky
 *
 */
public class PageListUtil {

	public static PageList buildPageList(List list) {
		if (list instanceof Page) {
			Page page = (Page) list;
			PageList pageList = new PageList();
			pageList.setPageNum(page.getPageNum());
			pageList.setPageSize(page.getPageSize());
			pageList.setStartRow(page.getStartRow());
			pageList.setEndRow(page.getEndRow());
			pageList.setTotal(page.getTotal());
			pageList.setPages(page.getPages());
			pageList.setList(list);
			return pageList;
		}
		return null;
	}

	public static PageList buildPageList(PageInfo page){
		if(page!=null){
			PageList pageList = new PageList();
			pageList.setPageNum(page.getPageNum());
			pageList.setPageSize(page.getPageSize());
			pageList.setStartRow(page.getStartRow());
			pageList.setEndRow(page.getEndRow());
			pageList.setTotal(page.getTotal());
			pageList.setPages(page.getPages());
			pageList.setList(page.getList());
			return pageList;

		}
		return null;
	}
}
